let inputEle = document.querySelector('.input')
let bodyEle = document.querySelector('.body')
inputEle.onkeyup = function(e) {
    if(e.keyCode == 13) {
      sendMessage()
    }
  }
  function sendMassage(w){
      if(inputEle.value && inputEle !==''){
          $.ajax({
              type:'get',
              url:'http:localhost:3000/user/sendmassage',
              data:{content:inputEle.value},
              success:function(result){
                  if(result.status === 'success'){
                      middle.innerHTML += '<div class="container">' + result.content + '</div>'
                      scrollToBottom(middle)
                  }
              }
          })
          inputEle.value = ''
      }
  }

  //*设置滚轮将聊天室的内容自动定位到最新
function scrollToBottom(ele){

    if(ele){
      ele.scrollTop = ele.scrollHeight 
    }
  }
   